package com.vinfai.common.util;

import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;

import com.vinfai.common.dao.impl.HibernateBaseDAOImpl;
import com.vinfai.demo.dao.impl.UserDAO;
import com.vinfai.hibernate4.entity.User;

public class ReflectionUtils {
	public static Class getSuperClassGenricType(final Class clazz, final int index) {
		Type genType = clazz.getGenericSuperclass();

		if (!(genType instanceof ParameterizedType)) {
			return Object.class;
		}

		Type[] params = ((ParameterizedType) genType).getActualTypeArguments();

		if (index >= params.length || index < 0) {
			return Object.class;
		}
		if (!(params[index] instanceof Class)) {
			return Object.class;
		}

		return (Class) params[index];
	}
	
	public static void main(String[] args){
		
		UserDAO dao = new UserDAO();
		System.out.println(dao.getEntityClazz());
	}
}
